package org.dairy.farms.model;

import org.dairy.farms.interceptor.hibernate.Auditable;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: gduggira
 * Date: Jul 12, 2011
 * Time: 4:53:18 PM
 */

@Table(name = "REVENUE")
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "REVENUE_BY")
public abstract class Revenue implements Auditable {
    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue
    private Long id;

    @ManyToOne
    @JoinColumn(name = "REVENUE_TYPE_ID", nullable = false)
    private RevenueType revenueType;

    @javax.persistence.Column(name = "AMOUNT")
    private float amount;

    @javax.persistence.Column(name = "PAYMENT_DATE")
    private Date paymentDate;

    public Long getId() {
        return id;
    }

    @OneToMany(mappedBy = "revenue",targetEntity = RevenueNotes.class,fetch = FetchType.LAZY,cascade = CascadeType.ALL)
    private Set<RevenueNotes> revenueNotes = new HashSet<RevenueNotes>();

    public void setId(Long id) {
        this.id = id;
    }

    public RevenueType getRevenueType() {
        return revenueType;
    }

    public void setRevenueType(RevenueType revenueType) {
        this.revenueType = revenueType;
    }

    public float getAmount() {
        return amount;
    }

    public void setAmount(float amount) {
        this.amount = amount;
    }

    public Date getPaymentDate() {
        return paymentDate;
    }

    public void setPaymentDate(Date paymentDate) {
        this.paymentDate = paymentDate;
    }

    public Set<RevenueNotes> getRevenueNotes() {
        return revenueNotes;
    }

    public void setRevenueNotes(Set<RevenueNotes> revenueNotes) {
        this.revenueNotes = revenueNotes;
    }

    @Embedded
    private AuditInfo auditInfo = new AuditInfo();
    public AuditInfo getAuditInfo() {
        return auditInfo;
    }

    public void setAuditInfo(AuditInfo auditInfo) {
        this.auditInfo = auditInfo;
    }
}
